﻿/* Copyright 2007-2008 dnAnalytics Project.
 *
 * Contributors to this file:
 * Patrick van der Velde
 * Marcus Cuda
 *
 * This file is part of dnAnalytics.  dnAnalytics is licensed under the 
 * Microsoft Public License. See License.txt for a complete copy of the
 * license.
 */
using System;
using System.IO;

namespace dnAnalytics.LinearAlgebra.IO
{
    /// <summary>
    /// Interface to write a single <see cref="Matrix"/> from a file or stream.
    /// </summary>
    public interface ISingleMatrixWriter
    {
        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given file. If the file already exists, 
        /// the file will be overwritten.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="file">The file to write the matrix to.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="file"/> is null.</exception>
        void WriteMatrix(Matrix matrix, string file);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given file. If the file already exists, 
        /// the file will be overwritten.
        /// </summary>
        /// <param name="matrix">the matrix to write.</param>
        /// <param name="file">The file to write the matrix to.</param>
        /// <param name="format">The format to use on each element.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="file"/> is null.</exception>
        void WriteMatrix(Matrix matrix, string file, string format);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given stream.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="stream">The <see cref="Stream"/> to write the matrix to.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="stream"/> is null.</exception>
        void WriteMatrix(Matrix matrix, Stream stream);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given stream.
        /// </summary>
        /// <param name="matrix">The <see cref="TextWriter"/> to write.</param>
        /// <param name="stream">The <see cref="Stream"/> to write the matrix to.</param>
        /// <param name="format">The format to use on each element.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="stream"/> is null.</exception>
        void WriteMatrix(Matrix matrix, Stream stream, string format);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given <b>TextWriter</b>.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="writer">The <see cref="TextWriter"/> to write the matrix to.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="writer"/> is null.</exception>
        void WriteMatrix(Matrix matrix, TextWriter writer);

        /// <summary>
        /// Writes the given <see cref="Matrix"/> to the given <b>TextWriter</b>.
        /// </summary>
        /// <param name="matrix">The matrix to write.</param>
        /// <param name="writer">The <see cref="TextWriter"/> to write the matrix to.</param>
        /// <param name="format">The format to use on each element.</param>
        /// <exception cref="ArgumentNullException">If either <paramref name="matrix"/> or <paramref name="writer"/> is null.</exception>
        void WriteMatrix(Matrix matrix, TextWriter writer, string format);
    }
}